package com.demo.hjh.thread;

public class MainSubThread extends Thread {
	

	public static void main(String[] args) throws InterruptedException {
		final Business business = new Business();
		new Thread(
				new Runnable() {
					
					@Override
					public void run() {
					
						for(int i=1;i<=50;i++){
							business.sub(i);
						}
						
					}
				}
		).start();
		
		for(int i=1;i<=50;i++){
			business.main(i);
		}
		
		
		Object o1 = new Object();
		Object o2 = new Object();
		boolean main=true;
		new MainSubThread().init();
		
		
	}
	void init(){
		Business business=new Business();
		for (int i = 0; i <= 50; i++) {
			business.main(i);
			business.sub(i);
		}
	}
}
class Business{
	synchronized void  main(int i){
		for (int j = 0; j <= 10; j++) {
			System.out.println(Thread.currentThread().getName()+"squ" +i+ "main class loop"+j);
		}
	}
	
	synchronized void sub(int i){
		for (int j = 0; j <= 100; j++) {
			System.out.println(Thread.currentThread().getName()+"squ" +i+ "sub class"+j);
		}
	}
}
